package com.sky.controller.admin;

import com.sky.dto.EmployeePageQueryDTO;
import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "套餐")
@RequestMapping("/admin/setmeal")
@RestController
public class SetmealController {
    @Autowired
    SetmealService service;
    /**
     * 新增套餐
     */
    @PostMapping
    public Result save(@RequestBody SetmealDTO setmealDTO){
        service.save(setmealDTO);
        return Result.success();
    }
    /**
     * 根据id查询套餐
     */
    @GetMapping("{id}")
    public Result setmealById(@PathVariable Long id){
        SetmealVO setmealVO = service.setmealById(id);
        return Result.success(setmealVO);
    }
    /**
     * 分页查询
     */
    @GetMapping("/page")
    public Result page( SetmealPageQueryDTO setmealPageQueryDTO){
        return Result.success(service.page(setmealPageQueryDTO));
    }
    /**
     * 起售 停售
     */
    @PostMapping("/status/{status}")
    public Result upDate(@PathVariable Integer status,Long id){
        service.upDate(status,id);
        return  Result.success();
    }
    /**
     * 删除
     */
    @DeleteMapping
    public Result delSetmeal(@RequestParam List<Long> ids){
        service.delSetmeal(ids);
        return Result.success();
    }
    /**
     *修改
     */
    @PutMapping
    public Result upSetmeal(@RequestBody SetmealDTO setmealDTO){
        service.upSetmeal(setmealDTO);
        return Result.success();
    }

}
